package routes

import (
	"soma-server/controller/system"
	"soma-server/middleware"

	"github.com/gin-gonic/gin"
)

func InitMenuRoutes(r *gin.RouterGroup, authMiddleware *middleware.JWTMiddleware) gin.IRoutes {
	menuController := controller.NewMenuController()
	router := r.Group("/menu")
	// 开启jwt认证中间件
	router.Use(authMiddleware.JWTAuthMiddleware())
	// 开启casbin鉴权中间件
	router.Use(middleware.CasbinMiddleware())
	{
		// 获取菜单树结构数据（树形数据表格）
		router.GET("/tree", menuController.GetMenuTree)
		// 创建菜单
		router.POST("/create", menuController.CreateMenu)
		// 更新菜单
		router.PUT("/update/:menuId", menuController.UpdateMenuById)
		// 删除菜单
		router.DELETE("/delete/batch", menuController.BatchDeleteMenuByIds)
		// 根据用户ID获取用户的权限(可访问)菜单树（左侧菜单栏）
		router.GET("/access/tree/:userId", menuController.GetUserMenuTreeByUserId)
	}

	return r
}
